<html>
<head><meta charset="utf-8"><title>List&lt;ExistentialPredicate&gt; · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/List.3CExistentialPredicate.3E.html">List&lt;ExistentialPredicate&gt;</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="209483134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/List%3CExistentialPredicate%3E/near/209483134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/List.3CExistentialPredicate.3E.html#209483134">(Sep 09 2020 at 08:17)</a>:</h4>
<p>We currently store trait objects as <code>Dynamic(Binder&lt;&amp;'tcx List&lt;ExistentialPredicate&lt;'tcx&gt;&gt;&gt;, Region&lt;'tcx&gt;)</code>.</p>
<p>Would it make sense to instead use something like the following here?</p>
<div class="codehilite"><pre><span></span><code><span class="cp">#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Ord, Eq, Hash, TyEncodable, TyDecodable)]</span><span class="w"></span>
<span class="cp">#[derive(HashStable, TypeFoldable)]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">DynamicTy</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">principal</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="n">ExistentialTraitRef</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">projection_bounds</span>: <span class="kp">&amp;</span><span class="na">&#39;tcx</span><span class="w"> </span><span class="n">List</span><span class="o">&lt;</span><span class="n">ExistentialProjection</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">auto_traits</span>: <span class="kp">&amp;</span><span class="na">&#39;tcx</span><span class="w"> </span><span class="n">List</span><span class="o">&lt;</span><span class="n">DefId</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>This would allow us to solve <a href="https://github.com/rust-lang/rust/issues/73815">#73815</a> in a more cleaner way, which would be nice</p>
<p>cc <span class="user-mention" data-user-id="116009">@nikomatsakis</span></p>



<a name="209483270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/List%3CExistentialPredicate%3E/near/209483270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/List.3CExistentialPredicate.3E.html#209483270">(Sep 09 2020 at 08:18)</a>:</h4>
<p>we currently have the <del>somewhat unchecked</del>(they are checked, I don't think there's a bug here, but the check is quite far away from the construction) invariants that there is only one principal type and at most one <code>projection</code> for every <code>DefId</code></p>



<a name="209500929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/List%3CExistentialPredicate%3E/near/209500929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/List.3CExistentialPredicate.3E.html#209500929">(Sep 09 2020 at 11:56)</a>:</h4>
<p>IIRC for the "one principal type" we wanted to avoid a construction that required one, because we eventually want to support multiple</p>



<a name="209501052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/List%3CExistentialPredicate%3E/near/209501052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/List.3CExistentialPredicate.3E.html#209501052">(Sep 09 2020 at 11:58)</a>:</h4>
<p>This'll also increase the size of that value quite a bit - I think 3x, roughly?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>